package br.com.cadele.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import br.com.cadele.model.Aluno;

public class AlunoDAO extends BaseDao {

	private static final long serialVersionUID = -1752152121443053222L;
	
	public AlunoDAO() {
		super();
	}
	
	public void executeSQL(String sql){
		super.executeSQL(sql);
		// TODO
	}
	
	public ArrayList<Aluno> executeQuery(String sql){
		ResultSet rs = getQueryResultSet(sql);
		ArrayList<Aluno> alunos = new ArrayList<Aluno>();
		try {
			Aluno aluno;
			while(rs.next()){
				aluno = new Aluno();
				aluno.setNome(rs.getString("nome"));
				aluno.setMatricula(rs.getString("matriculaAluno"));
				aluno.setCodigoCurso(Integer.parseInt(rs.getString("codigoCurso")));
				aluno.setCpf(rs.getString("cpf"));
				aluno.setEmail(rs.getString("email"));
				aluno.setEndereco(rs.getString("endereco"));
				alunos.add(aluno);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return alunos;
	}
}
